Imports System
Imports System.Web
Imports System.Web.UI.WebControls
Public Class feed_default
    Inherits System.Web.UI.Page
    Public objvalid As New gaValidation
    Public imgpath, currtURL As String
    Public oFeedbkCont As New gaFeedBack.FeedbackConts
    Public strErr As String
    Public bCont As Boolean = True
    Public sAccountID, sURL, sEmailAddress As String
    Public sCompany As String
    Public sMessageText
    Public sBrowserOS, sReferringURL As String
    Public nCompanyId, nDescriptionID As Integer
    Public aUserSession(13) As String
    Public feedOk As Boolean
    Public Const cSESSION_ID = 0
    Public Const cCOMPANY_ID = 1
    Public Const cGAPORTAL_ID = 2
    Public Const cUSER_ID = 3
    Public Const cINCIDCONTEXT = 4
    Public Const cINGIDCONTEXT = 5
    Public Const cLOGINDATETIME = 6
    Public Const cLASTACTIVITY = 7
    Public Const cUSERPERMISSIONSSTRING = 8
    'Public Const cTERMINAL_PIN = 9
    Public Const cROLE_ID = 9
    Public Const cMEMBER_TYPE = 10
    'Public Const cTERMINAL_NAME = 10
    Public Const cTERMINAL_NUMBER = 11
    Public Const cTERMINAL_MARKET = 12
    Protected WithEvents DescID As System.Web.UI.WebControls.DropDownList
    Protected WithEvents Director As System.Web.UI.WebControls.Button
    Protected WithEvents cancel As System.Web.UI.WebControls.Button
    Dim App_DSN As String = ConfigurationSettings.AppSettings("GASQLConnString")
    Dim oFeedbk As gaFeedBack.FeedbackConts
    Dim rst As New DataSet
#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    'NOTE: The following placeholder declaration is required by the Web Form Designer.
    'Do not delete or move it.
    Private designerPlaceholderDeclaration As System.Object

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        objvalid.getURL(Request.Url.ToString, imgpath, currtURL)
    End Sub
    Private Sub build_feedbackDesc()
        'Dim oFeedbk As gaFeedBack.FeedbackConts
        'Dim rst As New DataSet
        Dim i As Integer
        'DescID.Items.Clear()
        oFeedbk.DBConnectstring = App_DSN
        'DescID.add(new ListItem
        '<select name="DescriptionID">
        'Divlst.Items.Add(New ListItem("", ""))
        oFeedbk = New gaFeedBack.FeedbackConts
        oFeedbk.DBConnectstring = App_DSN
        rst = oFeedbk.feedbackform()

        If rst.Tables(0).Rows.Count > 0 Then
            For i = 0 To rst.Tables(0).Rows.Count - 1
                DescID.Items.Add(New ListItem(rst.Tables(0).Rows(i).Item("DescriptionText"), rst.Tables(0).Rows(i).Item("DescriptionID")))
            Next

        Else
            DescID.Items.Add(New ListItem("Unknown Report Type", "0"))

        End If

    End Sub
    Public Sub feedback()

        bCont = True

        '-----	initializing feedback variables
        sAccountID = ""   'Merchant ID that is submitting the form
        nCompanyId = 0
        sURL = ""     'URL that merchant is reporting on
        nDescriptionID = 0  'The type of feedback being submitted
        sEmailAddress = ""  'Email address of the merchant
        sMessageText = ""   'Feedback message text supplied by the merchant
        sBrowserOS = ""   'User agent information about the merchant's computing environment
        sReferringURL = " "  'The previous page of the form, where the user clicked to arrive at the form
        sCompany = ""           'The company that merchant belong to
        '-----	checking to see if merchant submitted the form.
        'If request.form("Director").count > 0 Then
        '-----	merchant submitted the form. gathering form, session, and server variables.

        'End If
    End Sub

    Private Sub Director_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Director.Click

        sAccountID = aUserSession(cINGIDCONTEXT)
        nCompanyId = aUserSession(cINCIDCONTEXT)
        sURL = Trim(Request.Form("URL"))
        nDescriptionID = CInt(Request.Form("DescriptionID"))
        sEmailAddress = Trim(Request.Form("EmailAddress"))
        sMessageText = Trim(Request.Form("MessageText"))
        sBrowserOS = Request.ServerVariables("HTTP_USER_AGENT")
        sReferringURL = Trim(Request.Form("ReferringURL"))
        sCompany = Trim(Request.Form("CompanyName"))
        '-----	fixing tick-mark problem with sending data to db
        If Len(sAccountID) > 0 Then
            sAccountID = Replace(sAccountID, "'", "''")
        End If
        If Len(sURL) > 0 Then
            sURL = Replace(sURL, "'", "''")
        End If
        If Len(sEmailAddress) > 0 Then
            sEmailAddress = Replace(sEmailAddress, "'", "''")
        End If
        If Len(sMessageText) > 0 Then
            sMessageText = Replace(sMessageText, "'", "''")
        End If
        If Len(sBrowserOS) > 0 Then
            sBrowserOS = Replace(sBrowserOS, "'", "''")
        End If
        If Len(sReferringURL) > 0 Then
            sReferringURL = Replace(sReferringURL, "'", "''")
        End If

        '-----	validating data
        If Len(sEmailAddress) > 0 Then
            If Not InStr(sEmailAddress, "@") > 0 Then
                bCont = False
                strErr = "Email Address appears to be invalid."
            End If
        End If

        If bCont Then
            '-----	creating sql statement to submit information to DB.
            oFeedbkCont = New gaFeedBack.FeedbackConts
            oFeedbkCont.DBConnectstring = App_DSN
            'entrydate = to_date('" & formatdatetime(now,vbshortdate) & "', 'mm/dd/yy')
            'entrydate = to_date('" & formatdatetime(now,vbshortdate) & "', 'dd/mm/yyyy')
            'nCompnayId = CID
            oFeedbkCont.sURL = Trim(Request.Form("URL"))
            oFeedbkCont.nDescriptionID = CInt(Request.Form("DescriptionID"))
            oFeedbkCont.sEmailaddress = Trim(Request.Form("EmailAddress"))
            oFeedbkCont.sMessageText = Trim(Request.Form("MessageText"))
            oFeedbkCont.sBrowserringURL = Request.ServerVariables("HTTP_USER_AGENT")
            oFeedbkCont.sReferringURL = Trim(Request.Form("ReferringURL"))
            oFeedbkCont.sCompany = Trim(Request.Form("CompanyName"))

            oFeedbkCont.ProductionName = Application("AppName")
            feedOk = oFeedbkCont.feedbackinfo(aUserSession(cINGIDCONTEXT), aUserSession(cINCIDCONTEXT))
            If feedOk Then
                Response.Redirect("ThankYou.asp")
            Else
                strErr = "submit feedback form failed."
            End If
        End If
    End Sub

    Private Sub cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cancel.Click

    End Sub
End Class
